﻿function ClientAddTab() {
    belongSite = document.getElementById("drpSelectSiteForTab").options[document.getElementById("drpSelectSiteForTab").selectedIndex].value;
    Url = Portal.SystemWebParts.Tab.Tab.GetAddTabUrl(belongSite).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, "_blank");
    //RealJumpPageTab();
}

function ClientSaveAddTab() {
    Alias = document.getElementById("txtAlias").value;
    TabName = document.getElementById("txtTabName").value;

    IndexOrder = document.getElementById("txtIndexOrder").value;

    ZoneFile = document.getElementById("dropSelectZoneTemplate").options[document.getElementById("dropSelectZoneTemplate").selectedIndex].value;
    LayoutFile = document.getElementById("dropSelectLayoutTemplage").options[document.getElementById("dropSelectLayoutTemplage").selectedIndex].value;
    belongSite = document.getElementById("txtBelongSite").value;
    Metadata = document.getElementById("txtMetadata").value;
    ZoneClass = document.getElementById("txtZoneClass").value;

    PersonalizationTypeIndex = document.getElementById("drpSelectPersonalizationType").selectedIndex;
    PersonalizationType = document.getElementById("drpSelectPersonalizationType").options[PersonalizationTypeIndex].value;

    PersonalizationZone = document.getElementById("txtPersonalizationZone").value;


    RetValue = Portal.SystemWebParts.Tab.AddTab.ServerSideAddTab(belongSite, Alias, TabName, LayoutFile, IndexOrder, ZoneFile, Metadata, ZoneClass, PersonalizationType, PersonalizationZone).value;
    if (RetValue.indexOf("ERROR") != -1) {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.close();
}

function ClientDeleteTab(TabId) {
    retValue = Portal.SystemWebParts.Tab.Tab.CheckSessionTimeOut().value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    retValue = Portal.SystemWebParts.Tab.Tab.ServerSideCheckAllowDeleteTab(TabId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    Msg = Portal.SystemWebParts.Tab.Tab.GetConfirmDeleteMsg().value;
    if (confirm(Msg) == false) return;
    RetValue = Portal.SystemWebParts.Tab.Tab.ServerSideDeleteTab(TabId).value;
    if (RetValue.indexOf("ERROR") != -1) {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    RealJumpPageTab();
}



function ShowClientUpdateUrlForm(TabId) {
    Url = Portal.SystemWebParts.Tab.Tab.GetShowUpdateForm(TabId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    //RealJumpPageTab();
    window.open(Url, "_blank");
}


function ClientShowDemo(TabId) {
    Url = Portal.SystemWebParts.Tab.Tab.GetShowFormDemo(TabId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, "_blank");
}


function ConfigClientShowDemo(TabId) {
    Url = Portal.SystemWebParts.Tab.ConfigTab.GetShowFormDemo(TabId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, "_blank");
}

function ConfigTab(TabId) {
    Url = Portal.SystemWebParts.Tab.Tab.GetConfigTabUrl(TabId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, "_blank");
}

function VirtualConfigTab(TabId) {
    Url = Portal.SystemWebParts.Tab.Tab.GetVirtualConfigTabUrl(TabId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, "_blank");
}

function GenerateTab(TabId) {

    retValue = Portal.SystemWebParts.Tab.Tab.GetConfirmGenerateMsg().value;
    if (confirm(retValue) == false) return;

    retValue = Portal.SystemWebParts.Tab.Tab.GetProcessingText().value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML = retValue;
    setTimeout("RealGenerateTab('" + TabId + "')", 10);
}

function RealGenerateTab(TabId) {
    Url = Portal.SystemWebParts.Tab.Tab.ServerSideGenerateTab(TabId).value;
    document.getElementById("divProcessing").innerHTML = "";
    alert(Url);
}

function ClientSaveUpdateTab(TabId) {
    belongSiteIndex = document.getElementById("drpSelectSiteTab").selectedIndex;
    belongSite = document.getElementById("drpSelectSiteTab").options[belongSiteIndex].value;
    Alias = document.getElementById("txtAlias").value;
    TabName = document.getElementById("txtTabName").value;
    DivLayout = document.getElementById("txtDivLayout").value;
    //SelectThemeIndex = document.getElementById("dropSelectStyleSheet").selectedIndex;
    StyleSheet = "";
    //    if (SelectThemeIndex != -1) {
    //        StyleSheet = document.getElementById("dropSelectStyleSheet").options[SelectThemeIndex].value;
    //    }
    IndexOrder = document.getElementById("txtIndexOrder").value;
    Zones = document.getElementById("txtZones").value;
    LoadType = "_runtime"; // document.getElementById("dropSelectLoadTypeForConfig").options[document.getElementById("dropSelectLoadTypeForConfig").selectedIndex].value;
    VirtualConfigCss = ""; // document.getElementById("txtVirtualConfigCss").value;
    PageTitle = document.getElementById("txtPageTitle").value;
    Metadata = document.getElementById("txtMetadata").value;
    ZoneClass = document.getElementById("txtZoneClass").value;
    PersonalizationTypeIndex = document.getElementById("drpSelectPersonalizationType").selectedIndex;
    PersonalizationType = document.getElementById("drpSelectPersonalizationType").options[PersonalizationTypeIndex].value;

    PersonalizationZone = document.getElementById("txtPersonalizationZone").value;


    RetValue = Portal.SystemWebParts.Tab.UpdateTab.ServerSideUpdateTab(TabId, belongSite, Alias, TabName, DivLayout, StyleSheet, IndexOrder, Zones, LoadType, VirtualConfigCss, PageTitle, Metadata, ZoneClass, PersonalizationType, PersonalizationZone).value;
    if (RetValue.indexOf("ERROR") != -1) {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.close();
}


function ShowClientTabItemUrlForm(TabId) {
    Url = Portal.SystemWebParts.Tab.Tab.GetShowTabItemsForm(TabId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, '_blank');
}

function ClientShowNewsItemForms(TabId) {
    Url = Portal.SystemWebParts.Tab.Tab.GetShowNewsItemForm(TabId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, '_blank');
}



function JumPageAvailableTab(TabId) {
    document.getElementById("divProcessingAvailable").innerHTML = Portal.SystemWebParts.Tab.TabInUser.GetProcessingText().value;
    setTimeout("RealJumPageAvailableTab('" + TabId + "')", 10);
}

function RealJumPageAvailableTab(TabId) {
    PageIndex = 0;
    if (document.getElementById("divSelectAvailableTab") != null) {
        PageIndex = document.getElementById("divSelectAvailableTab").selectedIndex;
    }
    Keyword = document.getElementById("txtAvailableKeyword").value;
    retValue = Portal.SystemWebParts.Tab.TabInUser.ReadingAvailableUser(TabId, Keyword, PageIndex).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessingAvailable").innerHTML = "";
    document.getElementById("divAvailableTab").innerHTML = retValue;
}



function JumPageAlreadyTab(TabId) {
    document.getElementById("divProcessingAlready").innerHTML = Portal.SystemWebParts.Tab.TabInUser.GetProcessingText().value;
    setTimeout("RealJumPageAlreadyTab('" + TabId + "')", 10);
}

function RealJumPageAlreadyTab(TabId) {
    PageIndex = 0;
    if (document.getElementById("divSelectAlreadyTab") != null) {
        PageIndex = document.getElementById("divSelectAlreadyTab").selectedIndex;
    }
    Keyword = document.getElementById("txtAlreadyKeyword").value;
    retValue = Portal.SystemWebParts.Tab.TabInUser.ReadingAlreadyUser(TabId, Keyword, PageIndex).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessingAlready").innerHTML = "";
    document.getElementById("divAlreadyTab").innerHTML = retValue;
}



function AssignUserToThisTab(UserId, TabId) {
    retValue = Portal.SystemWebParts.Tab.TabInUser.ServerSideAddUserToTab(UserId, TabId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    RealJumPageAvailableTab(TabId);
    RealJumPageAlreadyTab(TabId);
}


function RomoveUserFromThisTab(UserId, TabId) {
    if (confirm(Portal.SystemWebParts.Tab.TabInUser.GetConfirmDeleteMsg().value) == false) return;
    retValue = Portal.SystemWebParts.Tab.TabInUser.ServerSideRemoveUserFromTab(UserId, TabId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    RealJumPageAvailableTab(TabId);
    RealJumPageAlreadyTab(TabId);
}



function JumPageTab(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    document.getElementById("divProcessing").innerHTML = Portal.SystemWebParts.Tab.Tab.GetProcessingText().value;
    setTimeout("RealJumpPageTab(" + MaxItems + "," + ItemsPerRow + "," + NoOfVisiblePage + "," + CurrentPage + ",'" + JumpJavaScript + "')", 10);
}

function RealJumpPageTab(MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    Site = document.getElementById("drpSelectSiteForTab").options[document.getElementById("drpSelectSiteForTab").selectedIndex].value;
    Keyword = document.getElementById("txtKeywordForSearchTab").value;
    retValue = Portal.SystemWebParts.Tab.Tab.GetHtml(Site, Keyword, CurrentPage).value;

    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    document.getElementById("divTabMain").innerHTML = retValue;
}



function DetectWebPartDetail(TabId) {
    WebPartId = document.getElementById("drpSelectWebPart").options[document.getElementById("drpSelectWebPart").selectedIndex].value;
    document.getElementById("txtTitle").value = Portal.SystemWebParts.Tab.ConfigTab.ServerSideGetDefaultTitle(WebPartId).value;
    language = document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    document.getElementById("divSelectWebPartDetail").innerHTML = Portal.SystemWebParts.Tab.ConfigTab.ServerSideDetectWebPartDetail(language, TabId, WebPartId).value;
    DetectWebPartView(TabId);
    DetectWebPartLoadType(TabId);

}


function DetectWebPartView(TabId) {
    WebPartId = document.getElementById("drpSelectWebPart").options[document.getElementById("drpSelectWebPart").selectedIndex].value;
    document.getElementById("divSelectWebPartView").innerHTML = Portal.SystemWebParts.Tab.ConfigTab.ServerSideDetectWebPartView(TabId, WebPartId).value;
}

function DetectWebPartLoadType(TabId) {
    WebPartId = document.getElementById("drpSelectWebPart").options[document.getElementById("drpSelectWebPart").selectedIndex].value;
    document.getElementById("divSelectWebPartLoadType").innerHTML = Portal.SystemWebParts.Tab.ConfigTab.ServerSideDetectWebPartLoadType(TabId, WebPartId).value;
}


function ClientAddToZone(TabId) {
    language = document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    WebPartId = document.getElementById("drpSelectWebPart").options[document.getElementById("drpSelectWebPart").selectedIndex].value;
    Zone = document.getElementById("drpSelectZone").options[document.getElementById("drpSelectZone").selectedIndex].value;
    Id = document.getElementById("dropSelectData").options[document.getElementById("dropSelectData").selectedIndex].value;
    Title = document.getElementById("txtTitle").value;
    //LoadTypeIndex=document.getElementById("dropSelectLoadTypeForConfig").selectedIndex
    LoadType = "_runtime"; //document.getElementById("dropSelectLoadTypeForConfig").options[LoadTypeIndex].value;
    LoadTimeOut = "0"; // document.getElementById("txtLoadTimeOut").value;
    AppendStyleSheet = ""; // document.getElementById("txtAppendStyleSheet").value;
    ViewId = document.getElementById("dropSelectView").options[document.getElementById("dropSelectView").selectedIndex].value;
    ShowPorlet = document.getElementById("drpSelectPorletType").selectedIndex;
    ShowCaption = document.getElementById("drpSelectShowCaption").selectedIndex;
    Position = document.getElementById("txtPosition").value;

    retValue = Portal.SystemWebParts.Tab.ConfigTab.ServerSideAddModuleToZone(language, TabId, WebPartId, Zone, Title, Id, LoadType, LoadTimeOut, AppendStyleSheet, ViewId, ShowPorlet, ShowCaption, Position).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    alert(retValue);
    ClientLoadData(TabId);
}



function ClientUpdateTabModule(TabModuleId) {
    language = document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    Zone = document.getElementById("drpSelectZone").options[document.getElementById("drpSelectZone").selectedIndex].value;
    Title = document.getElementById("txtTitle").value;
    //LoadTypeIndex = document.getElementById("dropSelectLoadTypeForConfig").selectedIndex
    LoadType = "_runtime";// document.getElementById("dropSelectLoadTypeForConfig").options[LoadTypeIndex].value;
    LoadTimeOut = "0"; //document.getElementById("txtLoadTimeOut").value;
    AppendStyleSheet = document.getElementById("txtAppendStyleSheet").value;
    Position = document.getElementById("txtPosition").value;
    ViewId = document.getElementById("dropSelectView").options[document.getElementById("dropSelectView").selectedIndex].value;
    VisibleButton = document.getElementById("drpSelectVisibleButton").selectedIndex;
    ShowPorlet = document.getElementById("drpSelectPorletType").selectedIndex;
    ShowCaption = document.getElementById("drpSelectShowCaption").selectedIndex;
    SelectedIndexActive = document.getElementById("drpSelectActive").selectedIndex;
    Active = document.getElementById("drpSelectActive").options[SelectedIndexActive].value;
    ExtraStyleSheet = "";

    IdIndex = document.getElementById("dropSelectData").selectedIndex;
    Id = document.getElementById("dropSelectData").options[IdIndex].value;
    JumpLinkUrl = document.getElementById("txtJumpLinkUrl").value;

    retValue = Portal.SystemWebParts.Tab.UpdateTabModule.ServerSideUpdateTabModule(language, TabModuleId, Title, Zone, LoadType, LoadTimeOut, AppendStyleSheet, Position, ViewId, VisibleButton, ShowPorlet, ShowCaption, ExtraStyleSheet, Active, Id, JumpLinkUrl).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    alert(retValue);
    window.close();
}




function ClientLoadData(TabId) {
    document.getElementById("divProcessing").innerHTML = Portal.SystemWebParts.Tab.ConfigTab.GetProcessingText().value;
    setTimeout("RealClientLoadData('" + TabId + "')", 10);
}


function RealClientLoadData(TabId) {
    language = document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    Zone = document.getElementById("drpSelectZone").options[document.getElementById("drpSelectZone").selectedIndex].value;
    retValue = Portal.SystemWebParts.Tab.ConfigTab.LoadData(language, Zone, TabId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    document.getElementById("divDataContent").innerHTML = retValue;
}

function ClientDeleteModuleToZone(TabId, TabModuleId) {
    cMessage = Portal.SystemWebParts.Tab.ConfigTab.GetConfirmDeleteMsg().value;
    if (confirm(cMessage) == false) return;
    retValue = Portal.SystemWebParts.Tab.ConfigTab.ServerSideDeleteModuleToZone(TabModuleId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    ClientLoadData(TabId);
}

function ClientConfigModuleInZone(TabId, TabModuleId) {
    Url = Portal.SystemWebParts.Tab.ConfigTab.GetConfigModuleInZoneUrl(TabModuleId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    window.open(Url, '_blank');
    //    if(retValue.indexOf("ERROR")!=-1)
    //    {
    //        alert(retValue);
    //        return;
    //    }
}

function ClientUpdateModuleInZone(TabId, TabModuleId) {
    Url = Portal.SystemWebParts.Tab.ConfigTab.GetUpdateModuleInZoneUrl(TabModuleId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    //    if(retValue.indexOf("ERROR")!=-1)
    //    {
    //        alert(retValue);
    //        return;
    //    }
    //    ClientLoadData(TabId);
}


function GeneratePage() {
    retValue = Portal.SystemWebParts.Tab.Tab.CheckGeneratePage().value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    retValue = Portal.SystemWebParts.Tab.Tab.GetConfirmGenerateMsg().value;
    if (confirm(retValue) == false) return;

    retValue = Portal.SystemWebParts.Tab.Tab.GetGeneratePageProceesing().value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML = retValue;
    setTimeout("RealGeneratePage()", 10);
}

function RealGeneratePage() {
    belongSite = document.getElementById("drpSelectSiteForTab").options[document.getElementById("drpSelectSiteForTab").selectedIndex].value;
    retValue = Portal.SystemWebParts.Tab.Tab.GeneratePage(belongSite).value;
    document.getElementById("divProcessing").innerHTML = "";
    alert(retValue);
}


function PublishingPage() {
    retValue = Portal.SystemWebParts.Tab.Tab.ServerSideCheckPermissionRunDeploy().value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    retValue = Portal.SystemWebParts.Tab.Tab.GetConfirmGenerateMsg().value;
    if (confirm(retValue) == false) return;

    retValue = Portal.SystemWebParts.Tab.Tab.GetGeneratePageProceesing().value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML = retValue;
    setTimeout("RealPublishingPage()", 10);
}

function RealPublishingPage() {
    //document.getElementById("drpSelectVirtualDirectory").options[document.getElementById("drpSelectVirtualDirectory").selectedIndex].value;
    belongSite = document.getElementById("drpSelectSiteForTab").options[document.getElementById("drpSelectSiteForTab").selectedIndex].value;
    retValue = Portal.SystemWebParts.Tab.Tab.ServerSideRunDeploy(belongSite).value;
    document.getElementById("divProcessing").innerHTML = "";
    alert(retValue);
}



function GoDeployPage() {
    // document.getElementById("drpSelectVirtualDirectory").options[document.getElementById("drpSelectVirtualDirectory").selectedIndex].value;
    belongSite = document.getElementById("drpSelectSiteForTab").options[document.getElementById("drpSelectSiteForTab").selectedIndex].value;
    retValue = Portal.SystemWebParts.Tab.Tab.UrlPreviewDeploy(belongSite).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    window.open(retValue, "_blank");
}



function DetectTitle(TabModuleId) {
    language = document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    retValue = Portal.SystemWebParts.Tab.UpdateTabModule.GetTitle(language, TabModuleId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("txtTitle").value = retValue;
}

function EditStyleSheet(TabId) {
    Url = Portal.SystemWebParts.Tab.Tab.GetUpdateStyleSheetUrl(TabId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, '_blank');
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    //    if(retValue.indexOf("ERROR")!=-1)
    //    {
    //        alert(retValue);
    //        return;
    //    }
}


function ResetTab(TabId) {
    retValue = Portal.SystemWebParts.Tab.Tab.GetConfirmResetTabMsg().value;
    if (confirm(retValue) == false) return;
    retValue = Portal.SystemWebParts.Tab.Tab.GetProcessingText().value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML = retValue;
    setTimeout("RealResetTab('" + TabId + "')", 10);
}


function RealResetTab(TabId) {
    retValue = Portal.SystemWebParts.Tab.Tab.ResetTab(TabId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    JumPageTab();
    document.getElementById("divProcessing").innerHTML = retValue;
}

function SelectLayout(belongSite) {
    selectedIndex = document.getElementById("dropSelectLayoutTemplage").selectedIndex;
    selectedLayout = document.getElementById("dropSelectLayoutTemplage").options[selectedIndex].value;
    LayoutContent = Portal.SystemWebParts.Tab.UpdateTab.GetLayoutContent(belongSite, selectedLayout).value;
    document.getElementById("txtDivLayout").innerHTML = LayoutContent;
}


function SelectZone(belongSite) {
    selectedIndex = document.getElementById("dropSelectZoneTemplate").selectedIndex;
    selectedZoneFile = document.getElementById("dropSelectZoneTemplate").options[selectedIndex].value;
    ZoneContent = Portal.SystemWebParts.Tab.UpdateTab.GetZoneContent(belongSite, selectedZoneFile).value;
    document.getElementById("txtZones").innerHTML = ZoneContent;
}




function LoadPage() {
    selectedTabIndex = document.getElementById("drpSelectTab").selectedIndex;
    TabId = document.getElementById("drpSelectTab").options[selectedTabIndex].value;

    Url = Portal.SystemWebParts.Tab.ConfigTab.GetLoadPageUrl(TabId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, "_self");
}

function SavePosition(TabId) {
    MaxItems = document.getElementById("txtMaxModulesInZone").value;
    for (var Index = 0; Index < MaxItems; Index++) {
        tabModuleId = document.getElementById("txtId" + Index).value;
        Position = document.getElementById("txtPosition" + tabModuleId).value;
        Portal.SystemWebParts.Tab.ConfigTab.SavePosition(tabModuleId, Position);
    }
    alert(Portal.SystemWebParts.Tab.ConfigTab.SavePositionOk().value);
    ClientLoadData(TabId);
}


function ShowPermissionFuncForm(TabId) {
    Url = Portal.SystemWebParts.Tab.Tab.GetShowFormSetPermission(TabId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, '_blank');
}

function ShowCopyUrlForm(TabId) {
    Url = Portal.SystemWebParts.Tab.Tab.GetShowFormCopy(TabId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, '_blank');
}

function ClientDetectFromZone(TabId) {
    retValue = Portal.SystemWebParts.Tab.CopyZone.GetFromZone(TabId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divFromZone").innerHTML = retValue;
}

function ClientSaveCopyZone(ToTabId) {
    FromTabId = document.getElementById("drpSelectFromTab").options[document.getElementById("drpSelectFromTab").selectedIndex].value;
    FromZoneId = document.getElementById("drpSelectFromZone").options[document.getElementById("drpSelectFromZone").selectedIndex].value;
    ToZoneId = document.getElementById("drpSelectToZone").options[document.getElementById("drpSelectToZone").selectedIndex].value;
    retValue = Portal.SystemWebParts.Tab.CopyZone.ServerSideCopyZone(FromTabId, FromZoneId, ToTabId, ToZoneId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    alert(retValue);
}

function ClientDuplicateTab(TabId) {
    retValue = Portal.SystemWebParts.Tab.Tab.GetProcessingText().value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML = retValue;
    setTimeout("RealClientDuplicateTab('" + TabId + "')", 10);
}

function RealClientDuplicateTab(TabId) {
    cMessage = Portal.SystemWebParts.Tab.Tab.GetConfirmMsg().value;
    if (confirm(cMessage) == false) return;

    retValue = Portal.SystemWebParts.Tab.Tab.ServerSideDuplicateTab(TabId).value;
    if (retValue.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    alert(retValue);
    RealJumpPageTab();
}

function ClientSyncTab(TabId) {
    cMessage = Portal.SystemWebParts.Tab.Tab.GetConfirmMsg().value;
    if (confirm(cMessage) == false) return;
    document.getElementById("divProcessing").innerHTML = "Đang đồng bộ dữ liệu...";
    setTimeout("RealClientSyncTab('"+TabId+"')", 10);
}

function RealClientSyncTab(TabId) {
    retValue = Portal.SystemWebParts.Tab.Tab.ServerSideSyncTab(TabId).value;
    if (retValue.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    alert(retValue);
}

function ClientSaveUpdateStyleSheet(TabId) {
    StyleSheetText = document.getElementById("txtStyleSheet").value;
    Portal.SystemWebParts.Tab.UpdateStyleSheet.ServerSideUpdateStyleSheet(TabId, StyleSheetText);
    alert("Ghi lại thành công!");
    window.close();
}


function ClientSync() {
    cMessage = Portal.SystemWebParts.Tab.Tab.GetConfirmMsg().value;
    if (confirm(cMessage) == false) return;
    retValue = Portal.SystemWebParts.Tab.Tab.GetProcessingText().value;
    document.getElementById("divProcessing").innerHTML = retValue;
    setTimeout("RealClientSync()", 10);
}

function RealClientSync() {
    belongSite = document.getElementById("drpSelectSiteForTab").options[document.getElementById("drpSelectSiteForTab").selectedIndex].value;
    retValue = Portal.SystemWebParts.Tab.Tab.ServerSideSync(belongSite).value;
    if (retValue.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    alert(retValue);
}

function CopyZoneForMultiTab() {
    belongSite = document.getElementById("drpSelectSiteForTab").options[document.getElementById("drpSelectSiteForTab").selectedIndex].value;
    Url = Portal.SystemWebParts.Tab.Tab.GetShowFormCopyZoneForMultiTab(belongSite).value;
    if (Url.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, '_blank');
}

function UpdateMultiLayout() {
    belongSite = document.getElementById("drpSelectSiteForTab").options[document.getElementById("drpSelectSiteForTab").selectedIndex].value;
    Url = Portal.SystemWebParts.Tab.Tab.GetUrlUpdateLayout(belongSite).value;
    if (Url.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, '_blank');
}

function ClientCopyZoneForMultiTab(belongSite) {
    document.getElementById("divProcessing").innerHTML = Portal.SystemWebParts.Tab.CopyZoneForMultiTab.GetProcessingText().value;
    setTimeout("RealClientCopyZoneForMultiTab('" + belongSite + "')", 10);
}

function RealClientCopyZoneForMultiTab(belongSite) {
    MaxTab = document.getElementById("txtMaxTab").value;
    Zone = document.getElementById("drpSelectFromZone").options[document.getElementById("drpSelectFromZone").selectedIndex].value;
    for (var iIndex = 0; iIndex < MaxTab; iIndex++) {
        TabId = document.getElementById("TabId" + iIndex).value;
        checked = document.getElementById("CheckBox" + TabId).checked;
        if (checked) {
            retValue = Portal.SystemWebParts.Tab.CopyZoneForMultiTab.ServerSideCopyZone(Zone, TabId).value;
            if (retValue.indexOf("ERROR") != -1) {
                document.getElementById("divProcessing").innerHTML = "";
                alert(retValue);
                return;
            }
        }
    }
    document.getElementById("divProcessing").innerHTML = "";
    retValue = Portal.SystemWebParts.Tab.CopyZoneForMultiTab.ServerSideGetDone().value;
    alert(retValue);
}

function DoCheckAll() {
    MaxTab = document.getElementById("txtMaxTab").value;
    for (var iIndex = 0; iIndex < MaxTab; iIndex++) {
        TabId = document.getElementById("TabId" + iIndex).value;
        document.getElementById("CheckBox" + TabId).checked = true;
    }
}

function DoUnCheckAll() {
    MaxTab = document.getElementById("txtMaxTab").value;
    for (var iIndex = 0; iIndex < MaxTab; iIndex++) {
        TabId = document.getElementById("TabId" + iIndex).value;
        document.getElementById("CheckBox" + TabId).checked = false;
    }
}

function DoInvert() {
    MaxTab = document.getElementById("txtMaxTab").value;
    for (var iIndex = 0; iIndex < MaxTab; iIndex++) {
        TabId = document.getElementById("TabId" + iIndex).value;
        document.getElementById("CheckBox" + TabId).checked = !document.getElementById("CheckBox" + TabId).checked;
    }
}

function ClientUpdateLayoutForMultiTab(belongSite) {
    document.getElementById("divProcessing").innerHTML = Portal.SystemWebParts.Tab.UpdateLayoutForMultiTab.GetProcessingText().value;
    setTimeout("RealClientUpdateLayoutForMultiTab('" + belongSite + "')", 10);
}


function RealClientUpdateLayoutForMultiTab(belongSite) {
    MaxTab = document.getElementById("txtMaxTab").value;
    for (var iIndex = 0; iIndex < MaxTab; iIndex++) {
        TabId = document.getElementById("TabId" + iIndex).value;
        checked = document.getElementById("CheckBox" + TabId).checked;
        if (checked) {
            retValue = Portal.SystemWebParts.Tab.UpdateLayoutForMultiTab.ServerSideUpdateLayout(TabId).value;
            if (retValue.indexOf("ERROR") != -1) {
                document.getElementById("divProcessing").innerHTML = "";
                alert(retValue);
                return;
            }
        }
    }
    document.getElementById("divProcessing").innerHTML = "";
    retValue = Portal.SystemWebParts.Tab.UpdateLayoutForMultiTab.ServerSideGetDone().value;
    alert(retValue);
}


function ClientChangeExtraTheme() {
    SelectedIndex = document.getElementById("drpSelectExtraTheme").selectedIndex;
    ExtraTheme = document.getElementById("drpSelectExtraTheme").options[SelectedIndex].value;
    document.getElementById("txtAppendStyleSheet").value = ExtraTheme;
    document.getElementById("divPreviewExtraStyleSheet").innerHTML = "<img src='Preview/"+ExtraTheme+".jpg'>";
}

function ClientDetectInheritedZone() {
    SrcZone = document.getElementById("drpSelectZone").options[document.getElementById("drpSelectZone").selectedIndex].value;
    SelectInheritedTabIndex = document.getElementById("drpSelectInheritedTab").selectedIndex;
    SelectInheritedTab = document.getElementById("drpSelectInheritedTab").options[SelectInheritedTabIndex].value;
    SelectZone = Portal.SystemWebParts.Tab.ConfigTab.ServerSideDetectedInheritedZone(SelectInheritedTab, SrcZone).value;
    document.getElementById("divSelectInheritedZone").innerHTML = SelectZone;
}

function ClientSaveInheritedZone(SrcTabId) {
    SelectInheritedTabIndex = document.getElementById("drpSelectInheritedTab").selectedIndex;
    SelectInheritedTabId = document.getElementById("drpSelectInheritedTab").options[SelectInheritedTabIndex].value;

    SelectInheritedZone = "";
    if (document.getElementById("drpSelectInheritedZone") != null) {
        SelectInheritedZoneIndex = document.getElementById("drpSelectInheritedZone").selectedIndex;
        SelectInheritedZone = document.getElementById("drpSelectInheritedZone").options[SelectInheritedZoneIndex].value;
    }
    SrcZone = "";
    if (document.getElementById("drpSelectZone") != null) {
        SrcZone = document.getElementById("drpSelectZone").options[document.getElementById("drpSelectZone").selectedIndex].value;
    }
    MsgText = Portal.SystemWebParts.Tab.ConfigTab.ServerSideSaveInheritedZone(SrcTabId,SrcZone, SelectInheritedTabId, SelectInheritedZone).value;
    alert(MsgText);
}

function ClientSyncAll(belongSite) {
    retValue = Portal.SystemWebParts.Tab.Tab.GetConfirmGenerateMsg().value;
    if (confirm(retValue) == false) return;

    document.getElementById("divProcessing").innerHTML = Portal.SystemWebParts.Tab.Tab.GetProcessingText().value;
    setTimeout("RealClientSyncAll('" + belongSite + "')", 10);
}

function RealClientSyncAll(belongSite) {
    retValue = Portal.SystemWebParts.Tab.Tab.ServerSideSyncAllTab().value;
    if (retValue.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    alert(retValue);
}
